package com.triz.business.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.triz.common.annotation.Log;
import com.triz.common.core.controller.BaseController;
import com.triz.common.core.domain.AjaxResult;
import com.triz.common.enums.BusinessType;
import com.triz.business.domain.PatentSearch;
import com.triz.business.service.IPatentSearchService;
import com.triz.common.utils.poi.ExcelUtil;
import com.triz.common.core.page.TableDataInfo;

/**
 * 专利查询Controller
 * 
 * @author hlk
 * @date 2025-11-11
 */
@RestController
@RequestMapping("/business/patentSearch")
public class PatentSearchController extends BaseController
{
    @Autowired
    private IPatentSearchService patentSearchService;

    /**
     * 查询专利查询列表
     */
//    @PreAuthorize("@ss.hasPermi('business:patentSearch:list')")
    @GetMapping("/list")
    public TableDataInfo list(PatentSearch patentSearch)
    {
        startPage();
        List<PatentSearch> list = patentSearchService.selectPatentSearchList(patentSearch);
        return getDataTable(list);
    }

    /**
     * 导出专利查询列表
     */
//    @PreAuthorize("@ss.hasPermi('business:patentSearch:export')")
    @Log(title = "专利查询", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PatentSearch patentSearch)
    {
        List<PatentSearch> list = patentSearchService.selectPatentSearchList(patentSearch);
        ExcelUtil<PatentSearch> util = new ExcelUtil<PatentSearch>(PatentSearch.class);
        util.exportExcel(response, list, "专利查询数据");
    }

    /**
     * 获取专利查询详细信息
     */
//    @PreAuthorize("@ss.hasPermi('business:patentSearch:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(patentSearchService.selectPatentSearchById(id));
    }

    /**
     * 新增专利查询
     */
//    @PreAuthorize("@ss.hasPermi('business:patentSearch:add')")
    @Log(title = "专利查询", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PatentSearch patentSearch)
    {
        patentSearch.setCreateBy(getUsername());
        return toAjax(patentSearchService.insertPatentSearch(patentSearch));
    }

    /**
     * 修改专利查询
     */
//    @PreAuthorize("@ss.hasPermi('business:patentSearch:edit')")
    @Log(title = "专利查询", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PatentSearch patentSearch)
    {
        patentSearch.setUpdateBy(getUsername());
        return toAjax(patentSearchService.updatePatentSearch(patentSearch));
    }

    /**
     * 删除专利查询
     */
//    @PreAuthorize("@ss.hasPermi('business:patentSearch:remove')")
    @Log(title = "专利查询", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(patentSearchService.deletePatentSearchByIds(ids));
    }





}
